<template>

	<view class="product">
		<view class="video-box" v-if="productVideo && !wxCheckType">
			<video class="video-video" :src="productVideo" controls></video>
		</view>

		<!-- 		<vgt-tab @onValueChange='onValueChange' :itemStyleActive="{color: '#276aee'}" :list="titleList"
			:isUseOpenList="false">
		</vgt-tab> -->
		<!--    展示平铺的title-->
		<view class="product-list">
			<view v-for="(item, index) in titleList" :key="index"
				:class="['scroll-view-item_wrap', index === choseInd ? 'active-tag' : '']"
				@click="onClickListItem(index, item)">
				{{ item }}
			</view>
		</view>
		<view class="productDataWp">
			<view class="productDataItem" @click="goToProductDetail(item2)" v-for="(item2,index2) in productInfoList"
				:key="index2">
				<view class="imgWp">
					<u-image :src="item2.icon" width="80rpx" height="80rpx"></u-image>
				</view>
				<view class="productDataTitleWp">
					<view class="name">
						{{ item2.name }}
					</view>
					<view class="name">
						<u-icon name="arrow-right" color="#86909c" size="30"></u-icon>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import vgtTab from '@/pagesCard/components/vgt-tab/vgt-tab.vue'
	import { mapState } from 'vuex'

	export default {
		components: {
			vgtTab
		},
		props: {
			titleList: {
				type: Array,
				required: true
			},
			productInfoList: {
				type: Array,
				required: true
			},
			productVideo: {
				type: String,
			}

		},
		data() {
			return {
				choseInd: 0,
			}
		},
		computed: {
			...mapState(['wxCheckType']),
		},
		methods: {
			onClickListItem(index, data) {
				if (this.choseInd === index) return
				this.choseInd = index
				this.isShowList = false
				// this.calcPos(index)
				this.onValueChange({
					currentInd: index,
					currentItem: data
				})
				// this.$emit("onValueChange", {
				//   currentInd: index,
				//   currentItem: data
				// })
				this.$emit("onListShow", true)
			},
			onValueChange({
				currentInd
			}) {
				this.$emit('onValueChange', {
					currentInd
				})
			},
			goToProductDetail(item) {
				this.$emit('goToProductDetail', item)
			}

		}
	}
</script>

<style lang="scss" scoped>
	.product {

		.product-list {
			width: 100%;
			background-color: #f7f8fa;
			display: flex;
			overflow-x: auto;

			.scroll-view-item_wrap {
				min-width: 140rpx;
				padding: 12rpx 20rpx;
				text-align: center;
				font-size: 26rpx;
				border-radius: 8rpx;
				margin: 20rpx 0 0 20rpx;
				background: #fff;
			}

			.active-tag {
				color: #fff !important;
				background: #276AEE !important;
			}
		}

		.productDataWp {
			background-color: #f7f8fa;
			padding-top: 1rpx;
			padding-bottom: 20rpx;

			.productDataItem {
				display: flex;
				align-items: center;
				background-color: #fff;
				height: 112rpx;
				margin: 24rpx 32rpx;
				padding: 16rpx 24rpx;

				.imgWp {
					margin-right: 32rpx;
				}

				.productDataTitleWp {
					background-color: #fff;
					flex: 1;
					display: flex;
					justify-content: space-between;
					align-items: center;

					.name {
						padding: 10rpx 0;
						height: 40rpx;
						font-size: 28rpx;
						font-weight: 400;
						color: #1D2129;
						line-height: 39rpx;
					}
				}

			}
		}

		.video-box {
			padding: 20rpx 32rpx;
			background-color: #fff;

			.video-video {
				width: 686rpx;
				height: 320rpx;
			}
		}
	}
</style>